<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 服务中心-工单-工号 -->
    <style>

    </style>
</head>
<body>
<div class="scroll-content2 my-service-center-gd-gh" style="overflow:auto;background: #F6F6F8;">
    <div class="top-public">
        <span class="public-center">工单5790BMC</span>
        <img src="images/left_icon.png" alt="" class="public-left">
    </div>
    <div class="info-list">
        <ul>
            <li id="firstQuestion">
                <!-- <p>你好</p>
                <div class="list-info">机密信息：******</div>
                <div class="list-time">09-12 17:31</div>
                <div class="circle-l">我</div> -->
            </li>
            <!-- <li>
                <p>用户移动端关闭工单!</p>
                <div class="list-time">09-12 17:31</div>
                <div class="circle-s"></div>
            </li> -->
            <!-- <li>
                <p>整体评价：5星</p>
                <p>是否解决问题：未解决</p>
                <p>解决内容：无建议和意见</p>
                <div class="list-time">09-12 17:31</div>
                <div class="circle-s"></div>
            </li> -->
        </ul>
    </div>
    <div class="bot-bar">
        <ul>
            <li onclick="closegd()">关闭工单</li>
            <li onclick="again()">继续留言</li>
        </ul>
    </div>
    <div class="pop-up">
        <p>关闭工单</p>
        <span class="text">关闭工单是你不可退回的操作!确定要关闭工单吗?</span>
        <ul>
            <li onclick="qx()">取消</li>
            <li onclick="qd()">确定</li>
        </ul>
    </div>
    <div class="opacity-gray"></div>
    <div class="qx-cg">工单关闭成功</div>
    <a href="my_servicecenter_evaluate.html" class="bot-assess-box">
        <div class="bot-assess">
            <img src="images/daipinjia.png" alt="" class="dpj">
            <img src="images/xinxin12.png" alt="" class="star">
            <img src="images/xinxin12.png" alt="" class="star">
            <img src="images/xinxin12.png" alt="" class="star">
            <img src="images/xinxin12.png" alt="" class="star">
            <img src="images/xinxin12.png" alt="" class="star">
        </div>
    </a>
</div>
</body>
<script>
    $(function(){
        //验证是否登陆
        var user_id = sessionStorage.getItem('userId');
        if (user_id == null) {
            alert('请先登录！');
            window.location.href = 'login.html';
        }
        //获取工单详情
        getMessage();
    });
    //获取留言记录
    function getMessage(){
        var user_id = sessionStorage.getItem('userId');
        var wid = sessionStorage.getItem('wid');
        $.ajax({
            url: url() + 'api/Invoice/workDetails',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data:{
                wid:wid
            },
            success: function (data) {
                console.log(data);
                //请求成功时处理
                if(data.status==1){
                    var html1 = ''; //第一条固定数据
                    var html2 = '';
                    html1 = `
                        <p>${data.prom_list.description}</p>
                        <div class="list-info">机密信息：******</div>
                        <div class="list-time">${data.prom_list.add_time}</div>
                        <div class="circle-l">我</div>
                    `;
                    $('#firstQuestion').html(html1);
                    if(data.prom_list.status == 3){
                        // 已关闭-未评价
                        $('.bot-bar').css('display','none');
                        $('.bot-assess').css('display','block');
                        $('.bot-assess-box').attr('href','my_servicecenter_evaluate.html')
                    }else if(data.prom_list.status == 4){
                        // 工单已关闭
                        $('.bot-bar').css('display','none')
                    }else{
                        $('.bot-bar').css('display','block');
                    }
                    $.each(data.work, function (i, item) {
                        if(item.user_id == 0){
                            html2 = `
                                <li>
                                    <p>${item.comment}</p>
                                    <div class="list-time">${item.add_time}</div>
                                    <div class="circle-s"></div>
                                </li>
                            `;
                            $('.info-list ul').append(html2);
                        }else if(item.user_id == user_id){
                            html2 = `
                                <li id="firstQuestion">
                                    <p>${item.comment}</p>
                                    <div class="list-time">${item.add_time}</div>
                                    <div class="circle-l">我</div>
                                </li>
                            `;
                            $('.info-list ul').append(html2);
                        }
                    });
                    var html3 = '';
                    if (data.ping !=2) {
                        html3 = `
                        <li id="firstQuestion">
                                <p>整体评价：${data.ping.evaluation}星</p>
                                <p>是否解决问题：${data.ping.is_solve}</p>
                                <p>评价内容：${data.ping.feedback}</p>
                                <div class="list-time">${data.ping.add_time}</div>
                                <div class="circle-l">我</div>
                            </li>
                    `;
                        $('.info-list ul').append(html3);
                    }
                    $('#goodsList').html(html1)
                } else {
                    alert(data.msg);
                }
            }
        });
    }

    $('.public-left').click(function(){
        // window.history.go(-1);
        window.location.href = 'my_servicecenter_gd.html';
    });

    $('.tab-bar li').click(function () {
        $('.tab-bar li').removeClass('on_');
        $(this).addClass('on_').siblings().removeClass('on_');
        $(".main").eq($(this).index()).show().siblings().hide();
    });

    function closegd(){
        $('.pop-up').css('display','block');
        $('.opacity-gray').css('display','block');

    }
    function qx(){
        $('.pop-up').css('display','none');
        $('.opacity-gray').css('display','none');
    }

    // 确定关闭工单
    function qd(){
        var user_id = sessionStorage.getItem('userId');
        var wid = sessionStorage.getItem('wid');
        $('.pop-up').css('display','none');
        $('.opacity-gray').css('display','none');
        $.ajax({
            url: url() + 'api/Invoice/workClose',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data:{
                wid:wid,
                user_id:user_id
            },
            success: function (data) {
                console.log(data);
                //请求成功时处理
                if(data.status==1){
                    var html1 = `
                        <ul>
                            <li id="firstQuestion">

                            </li>
                        </ul>
                    `;
                    $('.info-list').html(html1);
                    $('.qx-cg').css('display','block');
                    setTimeout(() => {
                        $('.qx-cg').css('display','none');
                    }, 1000);
                    getMessage();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
    // 继续留言
    function again(){
        window.location.href = 'my_servicecenter_jxly.html';
    }
</script>
</html>






